<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/elementui.css">
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 150px;
            height: 70px;
            line-height: 150px;
            text-align: center;
        }
        .avatar {
            width: 150px;
            height: 70px;
            display: block;
        }

    </style>
</head>
<body>
  <div id="app">



      <!--弹出窗口-->
         <el-form label-width="90px">
              <el-form-item label="用户名">
                  <el-input	placeholder="用户名" v-model="pojo.username" @blur="autoLogin">
                  </el-input>
              </el-form-item>
             <el-form-item label="密码">
                 <el-input type="password"	placeholder="密码" v-model="pojo.userpass">
                 </el-input>
             </el-form-item>
             <el-form-item>
                 <el-checkbox-group v-model="pojo.check">
                     <el-checkbox label="记住我" name="1"></el-checkbox>
                 </el-checkbox-group>
             </el-form-item>

              <el-form-item>

                  <el-button @click="login()">登录</el-button>
              </el-form-item>
         </el-form>





  </div>
</body>
</html>
<script src="../js/axios.js"></script>
<script src="../js/vue.js"></script>
<script src="../js/elementui.js"></script>
<script>
    // 1. Vue.filter  定义一个全局过滤器

    new Vue({
        el: '#app',
        data() {
            return {
                pojo: {},
            }
        },
        created() {
           // alert("111");
         // this.fetchData();
        },
        methods:{
            autoLogin(){
                axios.get("user/autoLogin?username="+this.pojo.username).then(res=>{
                     if(res.data.code==0){
                         location.href="index.html";
                     }
                });
            },
            login(){
              axios.post(`user/login`,this.pojo).then(res=>{
                    if(res.data.code==0){
                        location.href="index.html";
                    }else{
                        this.$alert(res.data.message)
                    }
              }) ;
            },

        }
    })
</script>